package edu.csl.study.coreserver1.controller;
import edu.csl.study.coreserver1.vo.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**服务接口*/
@RestController
public class HelloController {
    Logger logger = LoggerFactory.getLogger(HelloController.class);
    /*注入“服务提供者”的名称*/
    /*注入“服务提供者”的端口号*/
    @Value("${server.port}")
    private String port;
    /*提供的接口，用于返回信息*/
    @RequestMapping("/hello")
    public String hello(HttpServletRequest request) {
        String params = request.getHeader("X-Request-Foo");
        logger.info("server1 - HelloController - hello 方法");
        String str="server1 端口port:" + port  ;
        //返回数据
        return str;
    }

    @GetMapping(value = "/user/get")
    public String updateUser1(User user){
        return "get方法：返回用户"+user.toString();
    }
    @PostMapping(value = "/user/post")
    public String updateUser2(@RequestBody User user){
        return "post方法：返回用户"+user.toString();
    }
}
